#include<iostream>
int recursion_all_wrong_sort(int n) {
	if (n == 1 || n == 2) {
		return n - 1;
	}
	else {
		return (recursion_all_wrong_sort(n - 1) + recursion_all_wrong_sort(n - 2)) * (n - 1);
	}
}
int all_wrong_sort(int n) {
	int arrays[1000];
	arrays[1] = 0;
	arrays[2] = 1;
	if (n == 1 || n == 2) {
		return arrays[n];
	}
	for (int i = 3; i <= n; i++) {
		arrays[i] = (i - 1) * (arrays[i - 1] + arrays[i - 2]);
	}
	return arrays[n];
}

int main() {
	int n = 0;
	std::cin >> n;
	std::cout << all_wrong_sort(n) << std::endl;;
	std::cout << recursion_all_wrong_sort(n) << std::endl;
}